(function(c) {
    var b = '<style type="text/css"></style>';
    c("head").append(b), c.fn.zxxbox = function(d) {
        return this.each(function() {
            var e = c.extend({}, a, d || {}), f = this.nodeName.toLowerCase();
            f === "a" && e.ajaxTagA ? c(this).click(function() {
                var g = c.trim(c(this).attr("href"));
                if (g) if (g.indexOf("#") >= 0) c.zxxbox(c(g), d); else if (/[\.jpg\.png\.bmp\.jpeg]$/i.test(g)) {
                    c.zxxbox.loading(d);
                    var h = new Image, i;
                    h.onload = function() {
                        var j = h.width, l = h.height;
                        if (j > 0) {
                            var k = c('<img src="' + g + '" width="' + j + '" height="' + l + '" />');
                            c.zxxbox(k, d);
                        }
                    }, h.onerror = function() {
                        var j = c('<div class="wrap_remind">图片加载失败！</div>');
                        c.zxxbox(j, d);
                    }, h.src = g;
                } else c.zxxbox.loading(d), c.get(g, {}, function(j) {
                    c.zxxbox(j, d);
                });
                return !1;
            }) : c.zxxbox(c(this), d);
        });
    }, c.zxxbox = function(f, d) {
        if (!f) return;
        var e = c.extend({}, a, d || {}), g = '<div id="zxxBlank" onselectstart="return false;"></div><div class="wrap_out" id="wrapOut"><div class="wrap_in" id="wrapIn"><div id="wrapBar" class="wrap_bar"  onselectstart="return false;"><div class="wrap_title"><span>' + e.title + '</span></div><a href="javasctipt:void(0);" class="wrap_close" id="wrapClose">' + e.shut + '</a></div><div class="wrap_body" id="wrapBody"></div></div></div>';
        c("#wrapOut").size() ? (c("#wrapOut").show(), e.bg ? c("#zxxBlank").show() : c("#zxxBlank").hide()) : c("body").append(g), typeof f == "object" ? f.show() : f = c(f), c.o = {
            "s": e,
            "ele": f,
            "bg": c("#zxxBlank"),
            "out": c("#wrapOut"),
            "bar": c("#wrapBar"),
            "clo": c("#wrapClose"),
            "bd": c("#wrapBody")
        }, c.o.bd.empty().append(f), c.isFunction(e.onshow) && e.onshow(), c.zxxbox.setSize(), c.zxxbox.setPosition(), e.fix && c.zxxbox.setFixed(), e.drag ? c.zxxbox.drag() : c(window).resize(function() {
            c.zxxbox.setPosition();
        }), e.bar ? c.zxxbox.barShow() : c.zxxbox.barHide(), e.bg ? c.zxxbox.bgShow() : c.zxxbox.bgHide(), e.btnclose ? c.o.clo.click(function() {
            return c.zxxbox.hide(), !1;
        }) : c.zxxbox.closeBtnHide(), e.bgclose && c.zxxbox.bgClickable(), e.delay > 0 && setTimeout(c.zxxbox.hide, e.delay), c.o.bg.click(function() {
            return c.zxxbox.hide(), !1;
        });
    }, c.extend(c.zxxbox, {
        "getSize": function(e) {
            var d = {};
            return c('<div id="wrapClone" style="position:absolute;left:-6000px;"></div>').appendTo("body").append(e.clone()), d.w = c("#wrapClone").width(), d.h = c("#wrapClone").height(), c("#wrapClone").remove(), d;
        },
        "setSize": function() {
            if (!c.o.bd.size() || !c.o.ele.size() || !c.o.bd.size()) return;
            var e = parseInt(c.o.s.width, 10), g = parseInt(c.o.s.height, 10);
            if (!e || e <= 0) {
                var f = c.zxxbox.getSize(c.o.ele), d = c(window).width();
                e = f.w, e < 50 ? e = 120 : e > d && (e = d - 120);
            }
            return c.o.bd.css("width", e), c.o.out.css("width", e + 2), g > 0 && c.o.bd.css("height", g), c.o.bd;
        },
        "setPosition": function(i) {
            i = i || !1;
            if (!c.o.bg.size() || !c.o.ele.size() || !c.o.out.size()) return;
            var k = c(window).width(), f = c(window).height(), n = c(window).scrollTop(), g = c("body").height();
            g < f && (g = f), c.o.bg.width(k).height(g).css("opacity", c.o.s.opacity);
            var j = c.o.out.outerHeight(), d = c.o.out.outerWidth(), m = n + (f - j) / 2, e = (k - d) / 2;
            return c.o.s.fix && window.XMLHttpRequest && (m = (f - j) / 2), i === !0 ? c.o.out.animate({
                "top": m,
                "left": e
            }) : c.o.out.css({
                "top": m,
                "left": e,
                "zIndex": c.o.s.index
            }), c.o.out;
        },
        "setFixed": function() {
            if (!c.o.out || !c.o.out.size()) return;
            return window.XMLHttpRequest ? c.zxxbox.setPosition().css({
                "position": "fixed"
            }) : c(window).scroll(function() {
                c.zxxbox.setPosition();
            }), c.o.out;
        },
        "bgClickable": function() {
            c.o.bg && c.o.bg.size() && c.o.bg.click(function() {
                c.zxxbox.hide();
            });
        },
        "bgHide": function() {
            c.o.bg && c.o.bg.size() && c.o.bg.hide();
        },
        "bgShow": function() {
            c.o.bg && c.o.bg.size() ? c.o.bg.show() : c('<div id="zxxBlank" onselectstart="return false;"></div>').prependTo("body");
        },
        "barHide": function() {
            c.o.bar && c.o.bar.size() && c.o.bar.hide();
        },
        "barShow": function() {
            c.o.bar && c.o.bar.size() && c.o.bar.show();
        },
        "closeBtnHide": function() {
            c.o.clo && c.o.clo.size() && c.o.clo.hide();
        },
        "hide": function() {
            return c.o.ele && c.o.out.size() && c.o.bg.size() && ((!c.o.ele.hasClass("wrap_remind") || c.o.ele.attr("id")) && c.o.ele.clone().hide().appendTo(c("body")), c.o.out.fadeOut("fast", function() {
                c(this).remove(), c.isFunction(c.o.s.onclose) && c.o.s.onclose();
            }), c.o.bg.fadeOut("fast", function() {
                c(this).remove();
            })), !1;
        },
        "drag": function() {
            if (!c.o.out.size() || !c.o.bar.size()) {
                c(document).unbind("mouseover").unbind("mouseup");
                return;
            }
            var h = c.o.bar, f = c.o.out, g = !1, e = 0, d = 0, j = f.css("left"), i = f.css("top");
            h.mousedown(function(k) {
                g = !0, e = k.clientX, d = k.clientY;
            }).css("cursor", "move"), c(document).mousemove(function(o) {
                if (g) {
                    var l = o.clientX, k = o.clientY, n = l - e, m = k - d;
                    f.css("left", parseInt(j) + n).css("top", parseInt(i) + m);
                }
            }), c(document).mouseup(function() {
                g = !1, j = f.css("left"), i = f.css("top");
            });
        },
        "loading": function(d) {
            var e = c('<div class="wrap_remind">加载中...</div>');
            d = d || {};
            var f = c.extend({}, d, {
                "bar": !1
            });
            c.zxxbox(e, f);
        },
        "ask": function(h, f, d, e) {
            var g = c('<div class="wrap_remind">' + h + '<p><button id="zxxSureBtn" class="submit_btn">确认</button>&nbsp;&nbsp;<button id="zxxCancelBtn" class="cancel_btn">取消</button></p></div>');
            c.zxxbox(g, e), c("#zxxSureBtn").click(function() {
                c.isFunction(f) && f.call(this);
            }), c("#zxxCancelBtn").click(function() {
                d && c.isFunction(d) && d.call(this), c.zxxbox.hide();
            });
        },
        "remind": function(f, g, d) {
            var e = c('<div class="wrap_remind">' + f + '<p><button id="zxxSubmitBtn" class="submit_btn">确认</button</p></div>');
            c.zxxbox(e, d), c("#zxxSubmitBtn").click(function() {
                g && c.isFunction(g) && g.call(this), c.zxxbox.hide();
            });
        },
        "ajax": function(e, f, d) {
            if (!f || typeof f != "object") f = {};
            e && (c.zxxbox.loading(d), c.get(e, f, function(g) {
                c.zxxbox(g, d);
            }));
        }
    });
    var a = {
        "title": "优惠券码",
        "shut": "×",
        "index": 2e3,
        "opacity": .5,
        "width": "auto",
        "height": "auto",
        "bar": !0,
        "bg": !0,
        "btnclose": !0,
        "fix": !1,
        "bgclose": !1,
        "drag": !1,
        "ajaxTagA": !0,
        "onshow": c.noop,
        "onclose": c.noop,
        "delay": 0
    };
})(jQuery);